package jian.hamster.game
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	import jian.hamster.event.GameTickerEvent;
	
	public class GameTicker extends EventDispatcher
	{
		
		private static var _instance:GameTicker;

		public static function get instance():GameTicker
		{
			return _instance ? _instance : (_instance = new GameTicker);
		}
		
		public function GameTicker(target:IEventDispatcher=null)
		{
			super(target);
			this.addEventListener(Event.ENTER_FRAME, __onEnterFrame);
		}
		
		protected function __onEnterFrame($event:Event):void
		{
			this.dispatchEvent(new GameTickerEvent(GameTickerEvent.GAME_FRAME));			
		}
	}
}